#include <iostream>

class Car // 抽象产品
{
public:
    virtual void show() = 0;
};

class BMW : public Car
{
public:
    BMW(int a) {}
    void show()
    {
        std::cout << "一辆宝马\n";
    }
};

class Benz : public Car
{
public:
    Benz(double b) {}
    void show()
    {
        std::cout << "一辆奔驰\n";
    }
};

class Audi : public Car
{
public:
    Andi(char c) {}
    void show()
    {
        std::cout << "一辆奥迪\n";
    }
};

class Factory // 抽象工厂
{
public:
    virtual Car *Create() = 0;
};

class BMWFactory:public Factory
{
public:
    Car *Create()
    {
        return new BMW(1);
    }
};

class BenzFactory:public Factory
{
public:
    Car *Create()
    {
        return new Benz(3.14);
    }
};

class AudiFactory:public Factory
{
public:
    Car *Create()
    {
        return new Audi('C');
    }
};

int main()
{
    Factory *f = new BMWFactory;
    Car *c = f->Create();
    c->show();
    return 0;
}
